package cn.io0288.blog2.db;

import cn.io0288.blog2.model.Article;
import cn.io0288.blog2.model.User;
import cn.io0288.blog2.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class Users {
    public User user;

    public Users(String uEmail) throws SQLException {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        user = null;

        connection = JdbcUtils.getConnection();
        String sql = "SELECT * FROM users WHERE `uemail`='%s'";
        sql = sql.formatted(uEmail);
        preparedStatement = connection.prepareStatement(sql);
        resultSet = preparedStatement.executeQuery();
        resultSet.next();

        user = new User(resultSet);

        System.out.println(user.toString());

        resultSet.close();
        preparedStatement.close();
        connection.close();
    }
}





